package com.pen.interfece.service.Impl;

import com.alibaba.dashscope.app.Application;
import com.alibaba.dashscope.app.ApplicationParam;
import com.alibaba.dashscope.app.ApplicationResult;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.pen.interfece.service.ModelService;
import org.springframework.stereotype.Service;

@Service
public class ModelServiceImpl implements ModelService {
    @Override
    public String callModel(String prompt) throws NoApiKeyException, InputRequiredException {
        ApplicationParam param = ApplicationParam.builder()
                .apiKey("sk-440a583d32594cdda32cb2b6459978c0")
                .appId("027247c25a0046adbdc22c278ad3be86")
                .prompt(prompt)
                .build();

        Application application = new Application();
        ApplicationResult result = application.call(param);
        String text = result.getOutput().getText();

        System.out.println(text);
        return text;
    }
}
